﻿using System;
using chatGUI.Model;
using System.Collections.ObjectModel;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Messaging;
using System.Collections.Generic;
using messageData;

namespace chatGUI.ViewModel
{
    class friendListViewModel : ViewModelBase
    {
        public friendListViewModel()
        {
            friendListData = new ObservableCollection<friendListModel>();
            Messenger.Default.Register<List<messageData.User>>(this, "friendData", initDataBaseFriends);
            Messenger.Default.Register<List<messageData.Group>>(this, "groupData", initDataBaseGroups);
            Messenger.Default.Register<CommunicateMessage>(this, "textMessage", checkMessage);
            Messenger.Default.Register<CommunicateMessage>(this, "gifMessage", checkMessage);
            Messenger.Default.Register<CommunicateMessage>(this, "imageMessage", checkMessage);
            Messenger.Default.Register<CommunicateMessage>(this, "fileMessage", checkMessage);
            Messenger.Default.Register<string>(this, "deleteFriend", deleteList);
            Messenger.Default.Register<string>(this, "withdrawGroup", deleteList);
            Messenger.Default.Register<User>(this, "addUserInFriendPanel", addFriendInPanel);
            friendListData.Add(new friendListModel{Id="111"});
        }
        private ObservableCollection<friendListModel> friendListData;
        public ObservableCollection<friendListModel> FriendListData
        {
            get { return friendListData; }
            set { Set(ref friendListData, value); }
        }
        private void initDataBaseFriends(List<messageData.User> users)
        {
        }
        private void initDataBaseGroups(List<messageData.Group> groups)
        {
        }
        private void checkMessage(CommunicateMessage communicateMessage)
        {
        }
        private void addFriendInPanel(User user)
        {
            friendListData.Add(new friendListModel
            {
                Id = user.uid,
                IsGroup = false,
                FriendNickName = user.uname,
            });
        }
        private void deleteList(string temp)
        {
        }
    }
}


